<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户设置</title>
    <link rel="stylesheet" type="text/css" href="../../public/home/css/style_1_common.css" />
    <link rel="stylesheet" type="text/css" href="../../public/home/css/style_1_forum_index.css" />
    <link rel="stylesheet" id="css_extstyle" type="text/css" href="../../public/home/css/style.css" />
    <script src="../../public/home/js/common.js" type="text/javascript"></script>
    <script src="../../public/home/js/forum.js" type="text/javascript"></script>
    <script src="../../public/home/js/jquery-3.3.1.js" type="text/javascript"></script>
    <style>
        #avatardesigner {
            border: 1px solid #CCC;
            padding: 10px;
            overflow: hidden;
        }
        #avatarfileselector {
            background: url(../../public/home/images/avatar_upload.gif) no-repeat;
            position: relative;
        }
    </style>
</head>
<body>
<?php require './head.php';?>
<div id="wp" class="wp">
    <div id="pt" class="bm cl">
        <div class="z">
            <a href="./" class="nvhm" title="首页">思爱婚介</a> <em>›</em>
            <a href="http://www.k99k99.com/home.php?mod=spacecp">设置</a> <em>›</em>个人资料
        </div>
    </div>
    <?php
            @$id = $_COOKIE['id1'];
            @$auth = $_COOKIE['uname1'];

    ?>
    <div id="ct" class="ct2_a wp cl">
        <div class="mn" id="ziliao">
            <div class="bm bw0">
                <h1 class="mt">个人资料
                </h1>
                <!--don't close the div here--><ul class="tb cl">
                    <li class="a"><a href="http://www.k99k99.com/home.php?mod=spacecp&amp;ac=profile&amp;op=base">基本资料</a></li>
                </ul><iframe id="frame_profile" name="frame_profile" style="display: none"></iframe>

                <form action="contro.php?a=update" method="post" enctype="multipart/form-data">
                    <input type="hidden" value=" <?php
                   echo $id;
                    ?>" name="id">

                    <table class="tfm" id="profilelist" cellspacing="0" cellpadding="0">
                        <tbody>
                            <?php

                            $sql = "select * from userdetail where uid = $id";
                            $result = mysqli_query($link,$sql);
                            while($rows = mysqli_fetch_assoc($result)){
                                $sex = $rows['sex'];
                                $work = $rows['work'];
                                $nickName = $rows['nickName'];
                                $email = $rows['email'];
                                $qq = $rows['qq'];
                                $age = $rows['age'];
                                $sex = $rows['sex'];
                                $num = $rows['num'];
                                $content = $rows['content'];
                                $phto = $rows['photo'];
                                $fh='x_';
                                $hz=basename($phto);
                                $logo1 = './images/'.$hz;
                                $logo ='./images/'.$fh.$hz;
                            }
                                mysqli_free_result($result);
                                mysqli_close($link);
                            ?>
                         <tr>
                        <th>用户名</th>
                          <td><input type="text" name="uname" readonly value='<?php echo $auth?>'></td>
                         </tr>
                        <tr>
                            <th><span class="rq">*</span>昵称</th>
                            <td><input type="text" name="nickName"  value='<?php echo $nickName?>'></td>
                        </tr>
                            <tr>
                                <th>email</th>
                                <td><input type="email" name="email"  value='<?php echo $email?>'></td>
                            </tr>
                            <tr>
                                <th>qq</th>
                                <td><input type="text" name="qq"  value='<?php echo $qq?>'></td>
                            </tr>
                            <tr>
                                <th>年龄</th>
                                <td><input type="text" name="age"  value='<?php echo $age?>'></td>
                            </tr>
                            <tr>
                                <th>性别</th>
                                <td><input type="radio" name="sex"  value='男'<?php echo $sex == '男'? 'checked':''?>>男&nbsp;&nbsp;
                                    <input type="radio" name="sex"  value='女'<?php echo $sex == '女'? 'checked':''?>>女</td>
                            </tr>
                            <tr>
                            <tr>
                                <th><span class="rq">*</span>联系方式</th>
                                <td><input id="num" type="text" name="num"  value='<?php echo $num?>'></td>
                                <script>
                                    $(function () {
                                        $("#num").focus(function(){
                                            $("#num").css("background-color","#fff");
                                        });
                                        $("#num").blur(function(){
                                            var num = $("#num").val();
                                            if(!(/^1[3|4|5|8][0-9]{9}$/.test(num))){
                                                alert('手机号码有误');
                                            }
                                        });
                                    })
                                </script>
                            </tr>
                                <th>工作情况</th>
                                <td><input type="radio" name="work"  value='有'<?php echo $work == '有'? 'checked':''?>>有&nbsp;&nbsp;
                                    <input type="radio" name="work"  value='无'<?php echo $work == '无'? 'checked':''?>>无</td>
                            </tr>
                            <th><span class="rq">*</span>交友宣言</th>
                            <td><textarea rows="10" cols="100"  name="jiao"  value=''><?php echo $content ?></textarea></td>
                            </tr>
                            <tr>
                            <td colspan="2">
                                <input type="hidden" name="profilesubmit" value="true">
                                <input  style="width: 80px" class="pn pnc" id="registerformsubmit" type="submit" name="regsubmit" value="保存" tabindex="1"><strong></strong></input>
                                <span id="submit_result" class="rq"></span>
                            </td>

                        </tr>

                        </tbody></table>

                </form>
                <div style="color:#FF0000;font-size:12px;text-align: center;">
                    <strong>重要提示：带*是必填项</strong>

                </div>
            </div>
        </div>
        <div class="mn" id="touxiang" style="display: none">
            <div class="bm bw0">
                <h1 class="mt">修改头像</h1>
                <!--don't close the div here--><script type="text/javascript">
                    function updateavatar() {
                        window.location.href = document.location.href.replace('&reload=1', '') + '&reload=1';
                    }
                    saveUserdata('avatar_redirect', document.referrer);
                </script>
                <form id="avatarform" method="post"  action="contro.php?a=upload"  enctype="multipart/form-data" >
                    <table class="tfm" cellspacing="0" cellpadding="0">
                        <input type="hidden" name="id" value="<?php echo $id?>">
                        <caption>
                            <span id="retpre" class="y xi2"></span>
                            <h2 class="xs2">当前我的头像</h2>
                            <p>如果您还没有设置自己的头像，系统会显示为默认头像，您需要自己上传一张新照片来作为自己的个人头像 </p>
                        </caption>
                        <tbody><tr>
                            <td><img src="<?php echo $logo ?>"></td>
                        </tr>
                        </tbody></table>

                    <table class="tfm" cellspacing="0" cellpadding="0">
                        <caption>
                            <h2 class="xs2" style="padding: 0;float: none">设置我的新头像</h2>
                            <p>请选择一个新照片进行上传编辑。<br>头像保存后，您可能需要刷新一下本页面(按F5键)，才能查看最新的头像效果 </p>
                        </caption>
                        <tbody><tr>
                            <td>
                                <div id="avatardesigner" style="width: 430px; height: 228px;">

                                    <form action="contro.php?a=upload" method="post" enctype="multipart/form-data">
                                        <img id="portrait" src="" style="display:none;" width="250px" height="150px"/>
                                        <input type="file" name="ufile" onchange="showPreview(this)"/><br><br>
                                        <input type="submit" value="上传">
                                    </form>
                                </div>
            <script type="text/javascript">
                function showPreview(source) {
                    var file = source.files[0];
                    if (window.FileReader) {
                        var fr = new FileReader();
                        console.log(fr);
                        var portrait = document.getElementById('portrait');
                        fr.onloadend = function (e) {
                            portrait.src = e.target.result;
                        };
                        fr.readAsDataURL(file);
                        portrait.style.display = 'block';
                    }
                }
            </script>
                            </td>
                        </tr>
                        </tbody></table>
                    <a href="http://www.k99k99.com/home.php?mod=spacecp&amp;ac=avatar&amp;old=1" class="xg1">如无法正常上传头像，请点此处切换为 Flash 方式上传</a>
                    <input type="hidden" name="formhash" value="96c977fd">
                </form>
            </div>
        </div>

        <div class="mn" id="mima" style="display: none">
            <div class="bm bw0">
                <h1 class="mt">密码安全
                </h1>
                <!--don't close the div here--><script src="data/cache/register.js?a6m" type="text/javascript"></script>
                <p class="bbda pbm mbm">
                    您必须填写原密码才能修改下面的资料</p>
                <form action="contro.php?a=upwd" method="post">
                    <table summary="个人资料" class="tfm" cellspacing="0" cellpadding="0">
                        <tbody><tr>
                            <input type="hidden" name="name" value="<?php echo $auth ?>">
                            <th><span class="rq" title="必填">*</span>旧密码</th>
                            <td><input type="password" name="oldpwd" id="oldpassword" class="px"></td>
                        </tr>
                        <tr>
                            <th>新密码</th>
                            <td>
                                <input type="password" name="newpwd" id="newpassword" class="px">
                                <p class="d" id="chk_newpassword">如不需要更改密码，此处请留空 </p>
                            </td>
                        </tr>
                        <tr>
                            <th>确认新密码</th>
                            <td>
                                <input type="password" name="newpwd2" id="newpassword2" class="px">
                                <p class="d" id="chk_newpassword2">如不需要更改密码，此处请留空 </p>
                            </td>
                        </tr>

                    <table summary="个人资料" class="tfm" cellspacing="0" cellpadding="0">
                        <tbody><tr>
                            <th>&nbsp;</th>
                            <td><button type="submit" name="pwdsubmit" value="true" class="pn pnc"><strong>保存</strong></button></td>
                        </tr>
                        </tbody></table>
                    <input type="hidden" name="passwordsubmit" value="true">
                </form>
                <script type="text/javascript">
                    var strongpw = new Array();
                    strongpw[0] = 1;
                    strongpw[1] = 2;
                    var pwlength = 6;
                    checkPwdComplexity($('newpassword'), $('newpassword2'), true);
                </script>
            </div>
        </div>

        <div class="appl"><div class="tbn">
                <h2 class="mt bbda" style="padding: 10px;float: none">设置</h2>
                <ul>
                    <li><button id="zi">个人资料</button></li>
                    <li><button id="gai">修改头像</button></li>
                    <li><button id="mi">密码安全</button></li>
                 </ul>
            </div></div>
    </div>	</div>
<?php require './footer.php';?>
<script>
          var gai = document.getElementById('gai');
          gai.onclick = function (ev) {
              document.getElementById('ziliao').style.display = 'none'
              document.getElementById('mima').style.display = 'none'
              document.getElementById('touxiang').style.display = 'block'

          }
          var mi = document.getElementById('mi');
          mi.onclick = function (ev) {
              document.getElementById('ziliao').style.display = 'none'
              document.getElementById('touxiang').style.display = 'none'
              document.getElementById('mima').style.display = 'block'
          }
          var zi = document.getElementById('zi');
          zi.onclick = function (ev) {
              document.getElementById('ziliao').style.display = 'block'
              document.getElementById('touxiang').style.display = 'none'
              document.getElementById('mima').style.display = 'none'
          }



</script>
</body>
</html>
